// pages/index/student/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        active: {
            type: Number,
            value: 0
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        tabBarActive: 0
    },



    /*
    *  生命周期函数，可以为函数
    * */
    lifetimes: {
        attached: function () {
            let active = this.data.active;
            this.setTitle(active);
            this.setData({tabBarActive: active});
        },
    },

    /**
     * 组件的方法列表
     */
    methods: {
        /*
        * 监听tabBar切换
        * */
        onTabBarChange: function (e) {
            let current = e.detail;
            let tabBarActive = this.data.tabBarActive;
            if (current === tabBarActive) {return false}
            this.setTitle(current);
            this.setData({tabBarActive: current})
        },

        setTitle: function (current) {
            let title = "";
            switch (current) {
                case 0:
                    title = "校友";
                    break
                case 1:
                    title = "消息";
                    break
                case 2:
                    title = "会员";
                    break
                default:
                    break
            }
            wx.setNavigationBarTitle({title: title})
        }
    }
})
